#ifndef GTIMER_H
#define GTIMER_H

#include "SYSTEM/sys/sys.h"

#define GTIM_TIMX_INT                  TIM3
#define GTIM_TIMX_INT_IRQn             TIM3_IRQn
#define GTIM_TIMX_INT_IRQHandler       TIM3_IRQHandler
#define GTIM_TIMX_INT_CLK_ENABLE()     __HAL_RCC_TIM3_CLK_ENABLE();

#define GTIM_TIMX_PWM_CHY_GPIO_PORT    GPIOB
#define GTIM_TIMX_PWM_CHY_GPIO_PIN     GPIO_PIN_5
#define GTIM_TIMX_PWM_CHY_GPIO_CLK_ENABLE()     __HAL_RCC_GPIOB_CLK_ENABLE()

#define GTIM_TIMX_PWM_CHY_GPIO_REMAP()      do {__HAL_RCC_AFIO_CLK_ENABLE();\
																								__HAL_AFIO_REMAP_TIM3_PARTIAL();\
																							 } while(0)

#define GTIM_TIMX_PWM_CHY              TIM_CHANNEL_2
#define GTIM_TIMX_PWM_CHY_CCRX         TIM3->CCR2
#define GTIM_TIMX_PWM_CHY_CLK_ENABLE() __HAL_RCC_TIM3_CLK_ENABLE();

extern TIM_HandleTypeDef g_timx_handle;

void gtim_timx_int_init(int arr, int psc);
void GTIM_TIMX_INT_IRQHandler(void);
																							 
void gtim_timx_pwm_chy_init(int arr, int psc);
void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim);

#endif
